﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace ArchiveAssistant.UI
{
  public partial class frmMain : Form
  {
    public frmMain()
    {
      InitializeComponent();
    }

    private void fillTreeDirectoriesNodes(TreeView view, string parentPath)
    {
      view.Nodes.Clear();
      var rootDirectoryInfo = new DirectoryInfo(parentPath);
      view.Nodes.Add(CreateDirectoryNode(rootDirectoryInfo));
    }

    private static TreeNode CreateDirectoryNode(DirectoryInfo directoryInfo)
    {
      var directoryNode = new TreeNode(directoryInfo.Name);
      foreach (var directory in directoryInfo.GetDirectories())
        directoryNode.Nodes.Add(CreateDirectoryNode(directory));
      foreach (var file in directoryInfo.GetFiles())
        directoryNode.Nodes.Add(new TreeNode(file.Name));
      return directoryNode;
    }

    private void frmMain_Load(object sender, EventArgs e)
    {
      slblStatus.Text = "Loading...";
      Cursor = Cursors.WaitCursor;
      fillTreeDirectoriesNodes(treeDirectories, @"C:\Development");
      //treeDirectories.Nodes.Add(new TreeNode("lala"));
      slblStatus.Text = "Ready";
      Cursor = Cursors.Default;
    }

    private void bkgdDirectoryScan_DoWork(object sender, DoWorkEventArgs e)
    {

    }

    private void bkgdDirectoryScan_ProgressChanged(object sender, ProgressChangedEventArgs e)
    {

    }

    private void bkgdDirectoryScan_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
    {

    }
  }
}
